#coding=utf-8

import types
from functools import wraps

class Profiled(object):

    def decorator1(self,func):
        @wraps(func)
        def wrapper(*args,**kwargs):
            print('Decorator 1')
            return func(*args,**kwargs)
        return wrapper

    @classmethod
    def decorator2(self,func):
        @wraps(func)
        def wrapper(*args,**kwargs):
            print('Decorator2')
            return func(*args,**kwargs)
        return wrapper


profiled = Profiled()
@profiled.decorator1
def add(x, y):
    return x+y

class Spam:
    @profiled.decorator2
    def bar(self,x):
        print (self,x)

    @Profiled.decorator2
    def bar2(self,x):
        print x

a = add(2,6)

b = Spam().bar(5)

c = Spam().bar(7)


